<!-- 专题推荐 -->
<template>
  <div>
    <el-card
      style="max-width: 100%;"
      class="card-table"
    >
      <search-box
        :tableDataInput="tableData"
        @search="handleSearch"
      ></search-box>
      <el-button
        class="btn1"
        @click="showDialog"
      ><i
          class="el-icon-plus"
          style="margin-right: 3px;"
        ></i>专题</el-button>

      <el-table
        :data="selectedItems"
        style="margin-top: 16px;font-size: 16px;"
        :header-cell-style="{ background: '#EBEEF2' }"
        row-key="id"
        default-expand-all
      >
        <el-table-column
          prop="logo"
          label="图标"
          align="center"
        >
          <template slot-scope="scope">
            <el-image
              style="width: 50px;height: 50px;"
              :src="scope.row.logo"
            ></el-image>
          </template>
        </el-table-column>
        <el-table-column
          prop="catName"
          label="专题名称"
          align="center"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          prop="productdetail"
          label="专题说明"
          align="center"
        />
        <el-table-column
          prop="pronumber"
          label="商品数量"
          align="center"
        />
        <el-table-column
          prop="status"
          label="启用状态"
          align="center"
        >
          <template slot-scope="scope">
            <el-switch
              v-model="scope.row.status"
              active-color="blue"
              inactive-color="gray"
              :active-value=1
              :inactive-value=0
            >
            </el-switch>
          </template>
        </el-table-column>
        <el-table-column
          prop="sort"
          label="排序"
          align="center"
        >
          <template slot-scope="scope">
            <div v-if="scope.row.sort === 1">
                <img
                  style="width: 16px;height: 16px;"
                  src="../assets/Main/sortup.png"
                
                />
            </div>

            <div v-if="scope.row.sort === 0">
                <img
                  style="width: 16px;height: 16px;"
                  src="../assets/Main/sortdown.png" 
               />
            </div>
          </template>
        </el-table-column>
        <el-table-column
          label="操作"
          width="300%"
        >
          <template slot-scope="scope">
            <div>
              <span @click="setproduct(scope.$index,scope.row)">
                <img
                  src="@/assets/setting.svg"
                  class="edit"
                >
                <span style="margin-left: 4px;">设置商品</span>
              </span>
              <span @click="edit(scope.$index,scope.row)">
                <img
                  src="@/assets/edit.svg"
                  class="edit"
                >
                <span style="margin-left: 4px;">编辑</span>
              </span>
              <span @click="deleted(scope.$index,scope.row)">
                <img
                  src="@/assets/delete.svg"
                  class="delete"
                >
                <span>删除</span>
              </span>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-pagination
          background
          layout="->,prev, pager,next,total"
          :page-size="3"
          :total="tableDataLength"
          @current-change="handleCurrentChange2"
          style="margin-top: 20px;"
        >
        </el-pagination>
    <add-recommend-vue v-if="addtitle" :visible.sync="addtitle" @close="closeadd"></add-recommend-vue>
  </div>

</template>

<script>
import AddRecommendVue from './components/AddRecommend.vue';
export default {
  name: "FeatureRecommend",
  components:{
    AddRecommendVue,
  },
  data() {
    return {
      selectedItems: [
        {
          id: 1,
          logo: require("@/assets/端午专卖.jpg"),
          catName: "端午专卖",
          productdetail:
            "专门未端午节期间推出的特别专卖，参加特卖商品必须与节日有关",
          pronumber: 345,
          status: 1,
          sort: 1,
        },
        {
          id: 2,
          logo: require("@/assets/端午专卖.jpg"),
          catName: "端午专卖",
          productdetail:
            "专门未端午节期间推出的特别专卖，参加特卖商品必须与节日有关",
          pronumber: 345,
          status: 1,
          sort: 1,
        },
        {
          id: 3,
          logo: require("@/assets/端午专卖.jpg"),
          catName: "端午专卖",
          productdetail:
            "专门未端午节期间推出的特别专卖，参加特卖商品必须与节日有关",
          pronumber: 345,
          status: 0,
          sort: 1,
        },
      ],
      tableData: [],
      tableDataLength: 3,
      addtitle: false,
    };
  },

  methods: {
    handleSearch(data) {},
    edit(index, row) {
      this.$message.info("编辑");
    },
    deleted(index, row) {
      this.$confirm("此操作将永久删除该记录, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.selectedItems.splice(index, 1);
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    setproduct(index, row) {
        
    },
    showDialog() {
        console.log("showDialog");
        this.addtitle = true;
        console.log("this.addtitle", this.addtitle);
    },
    closeadd(data){
        this.addtitle = false;
    },
    handleCurrentChange2(currentPage) {
        console.log("currentPage", currentPage);
    },
  },
};
</script>

<style>
.el-icon-arrow-right:before {
  content: "\e784";
}

.btn1 {
  position: absolute;
  right: 60px;
  opacity: 1;
  border-radius: 80px;
  width: 130px;
  height: 38px;
  color: white;
  font-size: 15px;
  background: rgba(126, 114, 242, 1);
}

.edit {
  width: 13.2px;
  height: 14px;
  position: relative;
  margin-left: 28px;
  top: 2px;
}

.delete {
  width: 13.2px;
  height: 16px;
  position: relative;
  top: 3px;
  margin-left: 28px;
  margin-right: 3px;
}
</style>